package com.ls.atf.core.web.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import com.ls.atf.core.web.WebPage;
import com.ls.atf.core.web.elements.Button;

public class ManageUsersPage extends WebPage<ManageUsersPage> {

	private static final String PAGE_URL = BASE_URL + "/admin_users";

	public ManageUsersPage(WebDriver driver) {
		super(driver);
	}

	@Override
	public ManageUsersPage load() {
		driver.get(PAGE_URL);
		return this;
	}

	@Override
	public boolean isAvailable() {
		return getAddNewUserButton().isAvailable();
	}
	
	public CreateUserPage goToCreateUserPage() {
		getAddNewUserButton().click();
		return new CreateUserPage(driver).waitUntilAvailable();
	}

	private Button getAddNewUserButton() {
		return new Button(driver,
				By.xpath("//a[contains(@href, 'admin_users/new')]"));
	}

}
